package gui.sidebar.transactions;

import exceptions.RelationAlreadyInSetException;
import exceptions.RelationNotInSetException;

import javax.swing.*;
import javax.swing.event.ListSelectionListener;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * Created by:  Jason Ye
 * Date:        16/02/2012
 * Time:        09:43
 */
public class ScrollableTransactionList extends JScrollPane{

    private JList transactionsList;
    private DefaultListModel model;
    private int relationID = 0;
    private Set<Integer> transactionIDs = new HashSet<Integer>();
    private Map<String, Integer> namesMapIds;

    public ScrollableTransactionList() {

        //init namesMapIds
        namesMapIds = new HashMap<String, Integer>();

        // init JList for transactions with defaultlistmodel which allows add/remove
        model = new DefaultListModel();
        transactionsList = new JList(model);

        // limit to single selections only - ie, only one relation at a time
        transactionsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);


        //add JList to scrollpane
        this.add(transactionsList);


    }

    /**
     * adds a selection listener to the list of relations
     *
     * @param listSelectionListener
     */
    public void addTransactionSelectionListener(ListSelectionListener listSelectionListener) {
        transactionsList.addListSelectionListener(listSelectionListener);
    }

    public void addTransaction(){

    }


}
